-
Notifications
You must be signed in to change notification settings - Fork 579
Added ensure_* functions #869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hm, doesn't seem like broken tests were caused by my changes. |
@pegasd I'm seeing similar failures in my windows modules on Travis :-( Suspect Travis just us a christmas present :-( |
@pegasd Tracking this in https://tickets.puppetlabs.com/browse/MODULES-6339 |
Can we retest this please? I'm assuming the issue has been fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this belongs in stdlib. Please publish this in your own module and namespace the function.
# } | ||
# } | ||
dispatch :ensure do | ||
param 'Variant[String, Boolean]', :ensure_param |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change the type to Enum[present, absent]
you would not need to check that in an else since you are guaranteed your method gets called with only one of those two values.
The original can be written: A more useful general purpose function would be something like a simple switch/swap value like: Closing this for now since commits and PR also must be marked with the ticket number. |
This CR adds a new function to case the ensureable property to a resource specific value. e.g. * stdlib::ensure('present', 'service') == 'running' * stdlib::ensure('present', 'directory') == 'directory' This is usefull when you want to pass ensure to a custome class and ensure all the resource get the correct value e.g. ``` class foo( Enum['present', 'absent'] $ensure = 'present' ) { file {'/some/dir': ensure => stdlib::ensure($ensure, 'directory') } file {'/some/file': ensure => stdlib::ensure($ensure, 'file') } file {'/some/link': ensure => stdlib::ensure($ensure, 'link') } service {'some-service': ensure => stdlib::ensure($ensure, 'service') } ``` something similar to this was discussed in puppetlabs#869
This CR adds a new function to case the ensureable property to a resource specific value. e.g. * stdlib::ensure('present', 'service') == 'running' * stdlib::ensure('present', 'directory') == 'directory' This is usefull when you want to pass ensure to a custome class and ensure all the resource get the correct value e.g. ``` class foo( Enum['present', 'absent'] $ensure = 'present' ) { file {'/some/dir': ensure => stdlib::ensure($ensure, 'directory') } file {'/some/file': ensure => stdlib::ensure($ensure, 'file') } file {'/some/link': ensure => stdlib::ensure($ensure, 'link') } service {'some-service': ensure => stdlib::ensure($ensure, 'service') } ``` something similar to this was discussed in puppetlabs#869
This CR adds a new function to case the ensureable property to a resource specific value. e.g. * stdlib::ensure('present', 'service') == 'running' * stdlib::ensure('present', 'directory') == 'directory' This is usefull when you want to pass ensure to a custome class and ensure all the resource get the correct value e.g. ``` class foo( Enum['present', 'absent'] $ensure = 'present' ) { file {'/some/dir': ensure => stdlib::ensure($ensure, 'directory') } file {'/some/file': ensure => stdlib::ensure($ensure, 'file') } file {'/some/link': ensure => stdlib::ensure($ensure, 'link') } service {'some-service': ensure => stdlib::ensure($ensure, 'service') } ``` something similar to this was discussed in puppetlabs#869
This CR adds a new function to case the ensureable property to a resource specific value. e.g. * stdlib::ensure('present', 'service') == 'running' * stdlib::ensure('present', 'directory') == 'directory' This is usefull when you want to pass ensure to a custome class and ensure all the resource get the correct value e.g. ``` class foo( Enum['present', 'absent'] $ensure = 'present' ) { file {'/some/dir': ensure => stdlib::ensure($ensure, 'directory') } file {'/some/file': ensure => stdlib::ensure($ensure, 'file') } file {'/some/link': ensure => stdlib::ensure($ensure, 'link') } service {'some-service': ensure => stdlib::ensure($ensure, 'service') } ``` something similar to this was discussed in puppetlabs#869
After seeing lots of these
I decided to implement helper functions and abstract this logic away.
Usage is as follows: